<?php

use yii\db\Migration;

/**
 * Class m181129_054136_create_sub_user
 */
class m181129_054136_create_sub_user extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%sub_user}}', [
            'id' => $this->primaryKey(),
            'uid' => $this->integer()->notNull()->comment('用户编号'),
            'username' => $this->string(128)->notNull()->comment('登录用户名'),
            'password' => $this->string(512)->notNull()->comment('登录密码'),
            'auth_key' => $this->string(32)->comment('Cookie验证字符串'),
            'status' => $this->integer()->notNull()->comment('状态'),
            'create_time' => $this->integer()->notNull()->comment('创建时间'),
        ]);
        $this->createIndex('fk_sub_user_user1_idx', '{{%sub_user}}', ['uid']);
        $this->addForeignKey('fk_sub_user_user1', '{{%sub_user}}', ['uid'], '{{%user}}', ['id']);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%sub_user}}');
    }
}
